import { Component, OnInit } from '@angular/core';
import { InteractiveService } from 'src/app/index/interactive.service';

declare var map: any;
declare var form: any;

@Component({
  selector: 'app-gis1',
  templateUrl: './gis1.component.html',
  styleUrls: ['./gis1.component.scss']
})
export class Gis1Component implements OnInit {

  // 显示更多内容
  moreTools = false;
  // 显示查询内容
  showSearch = false;

  constructor(public is: InteractiveService) {

  }

  ngOnInit() {
    map.Factory.create('mapui', {
      style: 'mapbox://styles/mapbox/outdoors-v10',
      center: [107.757, 38.259],
      zoom: 11,
      strategy: ['mapboxgl', 'openlayers', 'leaflet', 'cesium'],
      fullExtent: {
        xmin: 105.992204,
        ymin: 36.979711,
        xmax: 109.5338915,
        ymax: 39.543712
      }
    }, (o) => {
      form.ConfigService.map = o;
    });

    this.setLeftPanelHeight();
    window.addEventListener('resize', () => {
      this.setLeftPanelHeight();
    });
  }

  // 显示更多内容
  showMoreTools() {
    this.moreTools = !this.moreTools;
  }

  // 设置左边面板高度
  setLeftPanelHeight() {
    const height = window.innerHeight - 160;
    document.getElementById('map-sider-panel').style.height = height + 'px';
  }
}
